// pages/addcomplete/addcomplete.js
var imageUtil = require('../../utils/util.js');
// import { Data } from './addclock.data';
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    dietId: '',
  },
  // 转发
  onShareAppMessage: function () {
    return {
      title: '爱丁生活方式管理营',
    }
  },


  // 转发
  onShareAppMessage: function () {
    return {
      title: '爱丁生活方式管理营',
    }
  },

  //跳转首页
  returnbutton: function () {
    wx.switchTab({
      url: '../index/index',//跳转到首页页面tab
    })
  },


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that=this;
    that.setData({
      type: options.type,
      dietId: options.dietId
    })

    if (that.data.type == 9) {
      wx.setNavigationBarTitle({
        title: '月经打卡'
      })
    }

    app.getUserInfo(function (userInfo) {
      that.setData({ userInfo: userInfo })
    })

   
     
    let url = '/IbabyWebService/camp/dietDetail/' + that.data.dietId

      app.https.get(that, url, {}, function (res) {
        console.log(res)
        console.log(res.detail)
        try{
          var last = {};
            last.duration = JSON.parse(res.detail).duration;
            last.starttime = JSON.parse(res.detail).starttime;
            last.createtime = res.createtime;
            that.setData({
              'last': last,
            });
        } 
        catch (err) {
          console.log(err)
        }
      })
    
    
  },

// 修改添加
  modifysubmit: function () {
    wx.redirectTo({
      url: '../menstruation/menstruation?id=7&type=7&dietId=' + this.data.dietId + '&countday=' + this.data.last.duration + '&starttime=' + this.data.last.starttime,
    })
  },

 

})